package com.foo.cms.service.impl;

import com.foo.cms.service.BaseService;
import com.foo.cms.service.KeyworkService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: LZS
 * Date: 12-6-25
 * Time: 下午10:51
 * To change this template use File | Settings | File Templates.
 */
@Service
public class KeyworkServiceImpl extends BaseService implements KeyworkService {

    @Override
    public String getKeywork(String id) {
        String sql = "select k.vc2keyword from dt_keyword k , dt_article_keyword ak where ak.numkeywordid = k.numkeywordid and ak.numarticleid =  " + id;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, new HashMap<String, Object>());
        String keyword = "";
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = list.get(i);
            if (i != list.size() - 1) {
                keyword += (map.get("vc2keyword") + ";");
            } else {
                keyword += map.get("vc2keyword");
            }
        }
        return keyword;
    }
}
